package com.baizhi.service.impl;

import com.baizhi.dao.ClazzDao;
import com.baizhi.entity.Clazz;
import com.baizhi.service.ClazzService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class ClazzServiceImpl implements ClazzService {
    private ClazzDao cd;
    @Override
    public List<Clazz> selectAll() {
        return cd.selectAll();
    }

    @Override
    public PageInfo<Clazz> selectByPage(int pageNo, int pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<Clazz> clazzes = cd.selectAll();
        return new PageInfo<>(clazzes);
    }

    @Override
    public void insertTwo() {
        cd.insert(new Clazz("1111"));
//        if(true){
//            throw new RuntimeException("一个异常");
//        }
        cd.insert(new Clazz("2222"));
    }

    public ClazzDao getCd() {
        return cd;
    }

    public void setCd(ClazzDao cd) {
        this.cd = cd;
    }
}
